package light.head.controller.oa;

import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.format.UnderlineStyle;
import jxl.format.VerticalAlignment;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import light.head.constant.Msg;
import light.head.constant.Parm;
import light.head.constant.Sys;
import light.head.constant.Url;
import light.head.dao.oa.AuditStatusDAO;
import light.head.dao.oa.ReimburseDAO;
import light.head.dao.sys.MessageDAO;
import light.head.dao.sys.MessageTemplateDAO;
import light.head.dao.sys.OrganDAO;
import light.head.dao.sys.RoleDAO;
import light.head.dao.sys.UserInfoDAO;
import light.head.enm.RESULT;
import light.head.framework.base.SupporterController;
import light.head.framework.entity.PageBean;
import light.head.framework.utils.DateUtils;
import light.head.model.AuditStatus;
import light.head.model.Organ;
import light.head.model.Reimburse;
import light.head.model.ReimburseItem;
import light.head.model.UserInfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 申请单管理（物品申请审核菜单）
 * @author yy
 */
@Controller
@RequestMapping(value = Url.REIMBURSE_MANAGER)
public class ReimburseManagerController extends SupporterController {
	
	private ReimburseDAO reDAO;
	private OrganDAO organDAO;
	private AuditStatusDAO asDAO;
	private UserInfoDAO userDAO;
	private MessageTemplateDAO mtDAO;
	private MessageDAO msgDAO;
	private final static String sheetName = "报销统计";
	private RoleDAO roleDAO;
	

	@RequestMapping(value = Url.INIT)
	public ModelAndView init(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List<Integer> o = organDAO.getSonCodeList(cu_organCode(request));
		List<Organ> organ = organDAO.findOcs(o);
		request.setAttribute(Parm.ORGAN, organ);
		return new ModelAndView(Url.REIMBURSE_MANAGER_INIT);
	}
	
	@RequestMapping(value = Url.QUERY)
	public ModelAndView query(HttpServletRequest request, HttpServletResponse response) throws Exception {
		PageBean pb = createPageBean(request);
		Map<String, String> map = createQueryMapByParmName(request, Parm.DELETED, Parm.TIME1, Parm.TITLE, Parm.TIME2, Parm.PROJECT,Parm.OC,Parm.CN,Parm.PASS,Parm.SUC);
		String suc =map.get(Parm.SUC);
			// 获取根机构配置的物品申请流程节点
			if (reDAO.findByMap_1(organDAO.getSonCodeList(cu_organCode(request)), cu_roleCode(request), map, pb) == RESULT.SUCCESS) {
				// 讲对应的审核状态放到对应的
				Reimburse re = null;
				Double total = (double) 0;
				for (Object o : pb.getResultList()) {
					re = (Reimburse) o;
					List<ReimburseItem> itemList = reDAO.findApplyItem(re.getCode());
					for (ReimburseItem item : itemList) {
						total = total + item.getAmount();
					}
					re.setAuditStatusList(asDAO.findByBusinessMc(Sys.B_FOUR, re.getCode()));
				}
				if(suc != null && suc != ""){
					List<Object> list = reDAO.findSuc(organDAO.getSonCodeList(cu_organCode(request)), suc,map);
					StringBuffer result = new StringBuffer("[");
					for (Object obj1 : list) {
						Object[] obj = (Object[]) obj1;
						Integer code = (null == obj[0] || Sys.NONE.equals(obj[0].toString())) ? null : (Integer) obj[0];
						Double title = (null == obj[1] || Sys.NONE.equals(obj[1].toString())) ? null : (Double) obj[1];
						String name = reDAO.findCode(code);
						result.append("{"+ name +":"+ title);
						result.append("},");
					}
					result.deleteCharAt(result.length() - 1).append("]");
					request.setAttribute(Parm.TOTAL, result.toString());
				}else{
					request.setAttribute(Parm.TOTAL, total);
				}
				
			}
		request.setAttribute(Parm.PAGE_BEAN, pb);
		return new ModelAndView(Url.REIMBURSE_MANAGER_LIST);
	}

	// 单个申请单详情
	@RequestMapping(value = Url.DETAIL)
	public ModelAndView detail(Integer code, HttpServletRequest request, HttpServletResponse response) throws Exception {
		if (null != code) {
			Reimburse a = reDAO.get(code);
			if (null != a) {
				a.setAuditStatusList(asDAO.findByBusinessMcRc(Sys.B_FOUR, a.getCode(), cu_roleCode(request)));
				List<ReimburseItem> list = reDAO.findApplyItem(code);
				a.setItemList(list);
				request.setAttribute(Parm.REIMBURSE, a);
				Integer rc = roleDAO.findName("出纳", organDAO.getRoot(cu_organCode(request)).getCode());
				if(rc != null && cu_roleCode(request) == rc){
					request.setAttribute(Parm.ROLE, rc);
				}
			}
		}
		return new ModelAndView(Url.REIMBURSE_MANAGER_DETAIL);
	}

	
	@RequestMapping(Url.UPDATEDESIGNATE_1)
	public void updateDesignate1(String code,  HttpServletRequest request, HttpServletResponse response) throws Exception {
		RESULT result = RESULT.ERROR;
		// 查询当前申请信息是否已被当前用户审核
		List<AuditStatus> asList = asDAO.findByRcMcAuBusiness(cu_roleCode(request), Integer.parseInt(code), cu_code(request), Sys.B_FOUR);
		if (asList != null && asList.size() > 0 ) {
			print(response, Msg.EXISTS);
			return;
		}
		// 1.判断是否有审核权限 查询流程配置表
		List<AuditStatus> auList = asDAO.findByRcMcBusiness(cu_roleCode(request), Integer.parseInt(code), Sys.B_FOUR);
		if (auList == null || auList.size() == 0) {
			print(response, Msg.ERROR);
			return;
		}
		Reimburse re = reDAO.get(Integer.parseInt(code));
		//根据角色判断是否是移交的审核  是则走移交审核 不是则走普通审核
		AuditStatus aus = asDAO.findMcRc(Integer.parseInt(code), cu_roleCode(request), Sys.B_FOUR);
		AuditStatus aus1 = asDAO.findMcPc(aus.getPc(), Integer.parseInt(code), Sys.B_FOUR);
		if(aus1.getStatus() == Sys.B_FOUR){
			//修改上级审核状态
			aus.setStatus(Sys.B_ONE);
			asDAO.upd(aus);
			//修改当前审核状态
			aus1.setAt(new Date());
			aus1.setAu(cu_code(request));
			aus1.setStatus(Sys.B_ONE);
			asDAO.upd(aus1);
			
			//全部通过
			re.setPass(Sys.B_THREE);
			re.setPt(new Date());
			reDAO.upd(re);
			List<ReimburseItem> item = reDAO.findApplyItem(Integer.parseInt(code));
			re.setItemList(item);
			String content = mtDAO.throughToCu(re.getCt(), new Date());
			msgDAO.sendToUsers("【" + cu_realName(request) + "】审核通知", content, cu_code(request), cu_organCode(request), re.getCu());
			print(response,Msg.SUCCESS);
		
		}else{
			// 判断是否有上一级审核
			//Integer oc = organDAO.getRoot(cu_organCode(request)).getCode();
			Integer ishave = asDAO.ishave(cu_roleCode(request), Integer.parseInt(code), Sys.B_FOUR, organDAO.getSonCodeList(cu_organCode(request)));
			if (ishave !=null && ishave > 1) {
				// 2.判断上一级审核节点是否已经审核通过，查询流程配置表和审核状态表
				Byte beforeStatus = asDAO.checkBeforeByBusinessRc(Sys.B_FOUR, cu_roleCode(request), organDAO.getSonCodeList(cu_organCode(request)), Integer.parseInt(code));
				// 3.有审核权限，且上一级审核节点已经审核通过，进行保存本次审核状态
				if (beforeStatus == null || beforeStatus != Sys.B_ONE) {
					print(response, Msg.PARAMETER_ERROR);
					return;
				}
			}
			if (null != code) {
				List<AuditStatus> asList1 = reDAO.findAuditStatusBusiness(Integer.parseInt(code), cu_roleCode(request), Sys.B_FOUR);
				for (AuditStatus as : asList1) {
					as.setStatus(Sys.B_ONE);
					as.setAu(cu_code(request));
					as.setAt(new Date());
					result = asDAO.upd(as);
					// 查询是否有下一节点，有就修改下一节点审核状态为当前审核状态并发送消息通知下一审核人，没有就通知申请提交人
					List<AuditStatus> pcList = asDAO.findByOcPcMcBusiness(as.getPc() + 1, Integer.parseInt(code), Sys.B_FOUR);
					if (null != pcList && pcList.size() > 0) {
						for(AuditStatus aud : pcList){
							aud.setBeforeStatus(Sys.B_ONE);
							result = asDAO.upd(aud);
							Integer rc1 = userDAO.findByOc(aud.getCu(),aud.getOc());
							//下一节点审核人角色和申请人角色相同则直接通过，不相等则直接通知下一审核人
							if (null != rc1 && rc1 == aud.getRc()){
								aud.setStatus(Sys.B_ONE);
								aud.setAt(new Date());
								aud.setAu(aud.getCu());
								aud.setBeforeStatus(Sys.B_ONE);
								result = asDAO.upd(aud);
								// 查询是否有下一节点，有就修改下一节点审核状态为当前审核状态并发送消息通知下一审核人，没有就通知申请提交人
								List<AuditStatus> pc1List = asDAO.findByOcPcMcBusiness(aud.getPc() + 1, Integer.parseInt(code), Sys.B_FOUR);
								if (null != pcList && pcList.size() > 0) {
									for(AuditStatus ad : pc1List){
										ad.setBeforeStatus(Sys.B_ONE);
										result = asDAO.upd(ad);
									}
									//消息通知审核人 审核状态改为审核中
									re.setPass(Sys.B_FOUR);
									reDAO.upd(re);
									String name =userDAO.findCode(aud.getAu());
									Integer rc = asDAO.findByMcOcPc(aud.getOc(), aud.getMc(), aud.getPc() + 1);	// 获取该机构具有审核申请信息的角色编号
									if(null == rc ){
										print(response, Msg.ERROR);
										return;
									}
									List<UserInfo> userList = userDAO.findByRoleRc(cu_organCode(request), rc);	// 获取有审核角色的所有用户
									List<Integer> rucs = new ArrayList<Integer>();
									for (UserInfo u : userList) {
										rucs.add(u.getCode());
									}
									List<ReimburseItem> item = reDAO.findApplyItem(Integer.parseInt(code));
									re.setItemList(item);
									String content = mtDAO.applyFirstToTwo(re, re.getCn(), cu_realName(request), aud.getCt());
									msgDAO.sendToUsers("【" + name + "】提交申请单待审核通知", content, as.getCu(), cu_organCode(request), rucs);
									print(response,Msg.SUCCESS);
								} else {
									//全部通过
									re.setPass(Sys.B_THREE);
									re.setPt(new Date());
									reDAO.upd(re);
									List<ReimburseItem> item = reDAO.findApplyItem(Integer.parseInt(code));
									re.setItemList(item);
									String content = mtDAO.throughToCu(re.getCt(), as.getAt());
									msgDAO.sendToUsers("【" + cu_realName(request) + "】审核通知", content, cu_code(request), cu_organCode(request), re.getCu());
									print(response,Msg.SUCCESS);
								}
							} else {
								 //消息通知审核人 审核状态改为审核中
								re.setPass(Sys.B_FOUR);
								reDAO.upd(re);
								Integer rc = asDAO.findByMcOcPc(as.getOc(), as.getMc(), as.getPc() + 1);	// 获取该机构具有审核申请信息的角色编号
								if(null == rc ){
									print(response, Msg.ERROR);
									return;
								}
								List<UserInfo> userList = userDAO.findByRoleRc(cu_organCode(request), rc);	// 获取有审核角色的所有用户
								List<Integer> rucs = new ArrayList<Integer>();
								for (UserInfo u : userList) {
									rucs.add(u.getCode());
								}
								List<ReimburseItem> item = reDAO.findApplyItem(Integer.parseInt(code));
								re.setItemList(item);
								String content = mtDAO.applyFirstToTwo(re, re.getCn(), cu_realName(request), as.getAt());
								msgDAO.sendToUsers("【" + cu_realName(request) + "】提交申请单待审核通知", content, cu_code(request), cu_organCode(request), rucs);
								print(response,Msg.SUCCESS);
							}
						}
					} else if (RESULT.SUCCESS == result) {
						//全部通过
						re.setPass(Sys.B_THREE);
						re.setPt(new Date());
						reDAO.upd(re);
						List<ReimburseItem> item = reDAO.findApplyItem(Integer.parseInt(code));
						re.setItemList(item);
						String content = mtDAO.throughToCu(re.getCt(), as.getAt());
						msgDAO.sendToUsers("【" + cu_realName(request) + "】审核通知", content, cu_code(request), cu_organCode(request), re.getCu());
						print(response,Msg.SUCCESS);
					}
				}
			}
		}
	}
	
	@RequestMapping(Url.UPDATEDESIGNATE_2)
	public void updateDesignate2(String code, String remark,HttpServletRequest request, HttpServletResponse response) throws Exception {
		// 查询当前申请信息是否已被当前用户审核
		List<AuditStatus> asList =  asDAO.findByRcMcAuBusiness(cu_roleCode(request), Integer.parseInt(code), cu_code(request),Sys.B_FOUR);
		if (asList == null || asList.size() > 0) {
			print(response, Msg.EXISTS);
			return;
		}
		// 1.判断是否有审核权限 查询流程配置表
		List<AuditStatus> auList = asDAO.findByRcMcBusiness(cu_roleCode(request), Integer.parseInt(code), Sys.B_FOUR);
		if (auList == null || auList.size() < 0) {
			print(response, Msg.ERROR);
			return;
		}
		Reimburse re = reDAO.get(Integer.parseInt(code));
		//根据角色判断是否是移交的审核  是则走移交审核 不是则走普通审核
		AuditStatus aus = asDAO.findMcRc(Integer.parseInt(code), cu_roleCode(request), Sys.B_FOUR);
		AuditStatus aus1 = asDAO.findMcPc(aus.getPc(), Integer.parseInt(code), Sys.B_FOUR);
		if(aus1.getStatus() == Sys.B_FOUR){
			//根据编号的到上级审核数据
			aus.setStatus(Sys.B_TWO);
			asDAO.upd(aus);
			aus1.setAt(new Date());
			aus1.setAu(cu_code(request));
			aus1.setStatus(Sys.B_TWO);
			aus1.setRemark(remark);
			asDAO.upd(aus1);
			//保留驳回原因
			re.setRemark(cu_realName(request) + "驳回，原因：" + remark + re.getRemark());
			re.setPass(Sys.B_TWO);
			re.setPt(new Date());
			reDAO.upd(re);
			
			List<ReimburseItem> item = reDAO.findApplyItem(Integer.parseInt(code));
			re.setItemList(item);
			String content = mtDAO.rejectTofirst(re, cu_realName(request),aus1.getCt(), aus1.getRemark());
			msgDAO.sendToUsers("【" + cu_realName(request) + "】驳回了申请单", content, cu_code(request), cu_organCode(request), re.getCu());
			print(response,Msg.SUCCESS);
		}else{
			// 判断是否有上一级审核
			//Integer oc = organDAO.getRoot(cu_organCode(request)).getCode();
			Integer ishave = asDAO.ishave(cu_roleCode(request), Integer.parseInt(code), Sys.B_FOUR, organDAO.getSonCodeList(cu_organCode(request)));
			if (ishave !=null && ishave > 1) {
				// 2.判断上一级审核节点是否已经审核通过，查询流程配置表和审核状态表
				Byte status = asDAO.checkBeforeByBusinessRc(Sys.B_FOUR, cu_roleCode(request), organDAO.getSonCodeList(cu_organCode(request)), Integer.parseInt(code));
				// 3.有审核权限，且上一级审核节点已经审核通过，进行保存本次审核状态
				if (status == null || status != Sys.B_ONE) {
					print(response, Msg.PARAMETER_ERROR);
					return;
				}
			}
			if (null != code) {
				List<AuditStatus> asList1 = reDAO.findAuditStatusBusiness(Integer.parseInt(code), cu_roleCode(request),Sys.B_FOUR);
				
				//保留驳回原因
				re.setRemark(cu_realName(request) + "驳回，原因：" + remark + re.getRemark());
				re.setPass(Sys.B_TWO);
				re.setPt(new Date());
				reDAO.upd(re);
				for (AuditStatus as : asList1) {
					as.setStatus(Sys.B_TWO);
					as.setAu(cu_code(request));
					as.setAt(new Date());
					as.setRemark(remark);
					if (RESULT.SUCCESS == asDAO.upd(as)) {
						List<ReimburseItem> item = reDAO.findApplyItem(Integer.parseInt(code));
						re.setItemList(item);
						String content = mtDAO.rejectTofirst(re, cu_realName(request),as.getCt(), as.getRemark());
						msgDAO.sendToUsers("【" + cu_realName(request) + "】驳回了申请单", content, cu_code(request), cu_organCode(request), re.getCu());
						print(response,Msg.SUCCESS);
					}
				}
			}
		}
	}
	
	
	// 移交彭总
	@RequestMapping(value = Url.TRANSFER)
	public void transfer(Integer code,Integer pc,Integer cu, HttpServletRequest request, HttpServletResponse response) throws Exception {
		if (null != code && pc != null) {
			Reimburse a = reDAO.get(code);
			//Integer rc = roleDAO.findName("总经理", organDAO.getRoot(cu_organCode(request)).getCode());
			Integer rc = userDAO.findByRc(cu);
			if (null != a) {
				AuditStatus aus = asDAO.findMcRc(code, cu_roleCode(request), Sys.B_FOUR);
				if (cu == null) {
					print(response, Msg.PARAMETER_ERROR);
					return;
				}
				aus.setAu(cu_code(request));
				aus.setStatus(Sys.B_FOUR);
				aus.setAt(new Date());
				asDAO.upd(aus);
				AuditStatus as = new AuditStatus();
				as.setMc(code);
				as.setCu(a.getCu());
				as.setCt(a.getCt());
				as.setOc(a.getOc());
				as.setBusiness(Sys.B_FOUR);
				as.setRc(rc);
				as.setPc(pc + 1);
				as.setBeforeStatus(Sys.B_ONE);
				as.setStatus(Sys.B_FOUR);
				asDAO.add(as);
				print(response,Msg.SUCCESS);
			}
		}
	}

	@RequestMapping(Url.EXCEL)
	public void exportExcel(String oc,String time1,String time2, String suc,HttpServletRequest request, HttpServletResponse response) throws Exception{
		List<ReimburseItem> list = reDAO.findCode(organDAO.getSonCodeList(cu_organCode(request)),time1,time2,oc,suc);
			
			/**** 构造Excel文件 ****/
			response.reset();
			OutputStream os = response.getOutputStream();
			WritableWorkbook workbook = Workbook.createWorkbook(os);
			WritableSheet sheet = workbook.createSheet(sheetName, 0);

			// 单元格样式，用于标题
			WritableFont fnFont = new WritableFont(WritableFont.createFont("宋体"), 9, WritableFont.BOLD);
			WritableCellFormat wcf_title = new WritableCellFormat(fnFont);
			wcf_title.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
			wcf_title.setVerticalAlignment(VerticalAlignment.CENTRE);				// 垂直对齐
			wcf_title.setAlignment(Alignment.CENTRE);
			wcf_title.setWrap(true);												// 是否换行

			// 单元格样式，用于普通内容
			WritableFont fFont = new WritableFont(WritableFont.createFont("宋体"), 9);
			WritableCellFormat wcf_center = new WritableCellFormat(fFont);
			wcf_center.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
			wcf_center.setVerticalAlignment(VerticalAlignment.CENTRE);				// 垂直对齐
			wcf_center.setAlignment(Alignment.LEFT);
			wcf_center.setWrap(true);												// 是否换行

			// 单元格样式，用于无库存内容
			WritableFont noStockFont = new WritableFont(WritableFont.createFont("宋体"), 9, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLUE2);
			WritableCellFormat no_stock_center = new WritableCellFormat(noStockFont);
			no_stock_center.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
			no_stock_center.setVerticalAlignment(VerticalAlignment.CENTRE);				// 垂直对齐
			no_stock_center.setAlignment(Alignment.LEFT);
			no_stock_center.setWrap(true);												// 是否换行

			// 单元格样式，用于价格内容
			WritableFont noPriceFont = new WritableFont(WritableFont.createFont("宋体"), 9, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.RED);
			WritableCellFormat no_price_center = new WritableCellFormat(noPriceFont);
			no_price_center.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
			no_price_center.setVerticalAlignment(VerticalAlignment.CENTRE);				// 垂直对齐
			no_price_center.setAlignment(Alignment.LEFT);
			no_price_center.setWrap(true);												// 是否换行
			
			//表头
			sheet.setColumnView(0, 10);
			sheet.addCell(new Label(0, 0, "报销时间", wcf_title));
			sheet.setColumnView(1, 10);
			sheet.addCell(new Label(1, 0, "报销部门", wcf_title));
			sheet.setColumnView(2, 20);
			sheet.addCell(new Label(2, 0, "报销项目", wcf_title));
			sheet.setColumnView(3, 40);
			sheet.addCell(new Label(3, 0, "明细", wcf_title));
			sheet.setColumnView(4, 10);
			sheet.addCell(new Label(4, 0, "金额", wcf_title));
			
			for(int i = 0; i < list.size(); i++){
				 SimpleDateFormat dateformat1=new SimpleDateFormat("yyyy-MM-dd");
				Reimburse re = reDAO.get(list.get(i).getRbc());
				sheet.addCell(new Label(0, i + 1, dateformat1.format(re.getPt()), wcf_center));
				sheet.addCell(new Label(1, i + 1, re.getOn().toString(), wcf_center));
				sheet.addCell(new Label(2, i + 1, list.get(i).getProject().toString(), wcf_center));
				sheet.addCell(new Label(3, i + 1, list.get(i).getRemark().toString(), wcf_center));
				sheet.addCell(new Label(4, i + 1, list.get(i).getAmount().toString(), wcf_center));
			}
			String fileName = "报销统计表(" + DateUtils.getDateStr(new Date(), DateUtils.yyyy_MM_dd) + ").xls";
			response.setCharacterEncoding("UTF-8");
			response.setContentType("application/msexcel; charset=UTF-8");
			response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes("GBK"), "ISO8859_1"));
			workbook.write();
			workbook.close();
			os.flush();
			os.close();
	}
	
	
	/**
	 * 查询公开人
	 */
	@RequestMapping(Url.AID_INIT)
	public ModelAndView aidUserInit(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String a = request.getParameter(Parm.A);
		request.setAttribute(Parm.A, a);
		return new ModelAndView(Url.REIMBURSE_MANAGER_USERINIT);
	}

	@RequestMapping(Url.AID_LIST)
	public ModelAndView aidUserList(HttpServletRequest request, HttpServletResponse response) throws Exception {
		PageBean pageBean = createPageBean(request);
		Map<String, String> map = createQueryMapByParmName(request, Parm.PROJECT, Parm.SUC, Parm.OC);
		if (RESULT.SUCCESS == reDAO.findSubUsers(organDAO.getSonCodeList(cu_organCode(request)), map, pageBean)) {
			request.setAttribute(Parm.PAGE_BEAN, pageBean);
		}
		return new ModelAndView(Url.REIMBURSE_MANAGER_USERLIST);
	}
	
	@RequestMapping(value = Url.SELECTEDUSERINIT)
	public ModelAndView selectedUserInit(HttpServletRequest request, HttpServletResponse response) throws Exception {
		request.setAttribute(Parm.ID, request.getParameter(Parm.ID));
		request.setAttribute(Parm.NAME, request.getParameter(Parm.NAME));
		return new ModelAndView(Url.REIMBURSE_MANAGER_SELECTUSERINIT);
	}
	
	@RequestMapping(value = Url.SELECTEDUSERLIST)
	public ModelAndView selectedUserList(HttpServletRequest request, HttpServletResponse response) throws Exception {
		PageBean pb = createPageBean(request);
    	Map<String, String> map = createQueryMapByParmName(request, Parm.NAME);
    	userDAO.findByMap(map, pb);
    	request.setAttribute(Parm.PAGE_BEAN, pb);
		return new ModelAndView(Url.REIMBURSE_MANAGER_SELECTUSERLIST);
	}
	

	@Autowired
	public void setReDAO(ReimburseDAO reDAO) {
		this.reDAO = reDAO;
	}
	@Autowired
	public void setOrganDAO(OrganDAO organDAO) {
		this.organDAO = organDAO;
	}
	@Autowired
	public void setAsDAO(AuditStatusDAO asDAO) {
		this.asDAO = asDAO;
	}
	@Autowired
	public void setUserDAO(UserInfoDAO userDAO) {
		this.userDAO = userDAO;
	}
	@Autowired
	public void setMtDAO(MessageTemplateDAO mtDAO) {
		this.mtDAO = mtDAO;
	}
	@Autowired
	public void setMsgDAO(MessageDAO msgDAO) {
		this.msgDAO = msgDAO;
	}
	@Autowired
	public void setRoleDAO(RoleDAO roleDAO) {
		this.roleDAO = roleDAO;
	}
	
}
